package com.scwatch.core.mq;

import com.scwatch.core.service.CodeDevService;
import com.scwatch.core.service.InfoService;
import com.scwatch.core.service.InviteService;
import com.scwatch.core.service.impl.InfoServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Service;

/**
 * Created by gjl on 2017/12/7.
 */
@Service
public class MQConsumerService {

    private static final Logger logger = LoggerFactory.getLogger(InfoServiceImpl.class);
    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;
    @Autowired
    private InfoService infoService;
    @Autowired
    private InviteService inviteService;

    @JmsListener(destination = "city.sendCityInfo")
    public void receiveCityQueue(String text) {
        try {
            logger.info("----接收市州mq开始----");
            infoService.pubCityInfoQueue(text);
            logger.info("----接收市州mq结束----");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @JmsListener(destination = "city.inviteCode")
    public void receiveCityInviteCode(String text) {
        try {
            logger.info("----接收市州邀请码开始----text："+text);
            inviteService.saveCityInviteCodeQueue(text);
            logger.info("----接收市州邀请码结束----");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}